<h1> Now Viewing: <%= @user.person.name %> </h1>

<form>
  <h3> Personal Information </h3>
  <div class="show_container">
    <p>
      <label>Name</label> <br />
      <span class="show_info"><%= @user.person.name %></span>
    </p>
    <p>
      <label>Phone</label> <br />
      <span class="show_info"><%= @user.person.phone %></span>
    </p>
  </div>
  <br />
  <h3> User Information </h3>
  <div class="show_container">
    <p>
      <label>Email</label> <br />
      <span class="show_info"><%= @user.email %> </span>
    </p>
    <p>
      <label>Created</label> <br />
      <span class="show_info"><%=h time_ago_in_words(@user.created_at) << " ago" %> </span>
    </p>
  </div>
  <br />
  <h3> Roles </h3>
  <div class="show_container">
    <p>
      <span class="show_info">
        <% @user.person.roles.each do |role| %>
          <%= image_tag("/images/icons/roles/16-#{role}.png", :alt => "#{role}", :title => "#{role}", :class => "icon") << "#{role}"%><%= " " unless role == @user.person.roles.last %>
        <% end %>
        <% if !@user.person.is_active? %>
          <%= image_tag("/images/icons/png-8/16-circle-red-delete.png", :alt => "inactive", :title => "This user is inactive", :class => "icon") << "inactive"%>
        <% else %>
          <%= image_tag("/images/icons/png-8/16-circle-green-check.png", :alt => "active", :title => "This user is active", :class => "icon") << "active" %>
        <% end %>
      </span>
    </p>
  </div>
  <br />
  <h3> Stats </h3>
  <div class="show_container">
    <p>
      <span class="show_info"> <%=  @user.person.events.count %> events volunteered </span> <br />
      <% if @user.person.events.count > 0 %>
        <% @user.person.events.each do |event| %>
          <i> <%= event.name %> - about <%= time_ago_in_words(event.ends_at)  %> ago</i><br />
        <% end %>
        <br />
      <% end %>
      <span class="show_info"> <%=  @user.person.visitor.events.count %> events attended </span> <br />
      <% if @user.person.visitor.events.count > 0 %>
        <% @user.person.visitor.events.each do |event| %>
          <i> <%= event.name %> - about <%= time_ago_in_words(event.ends_at)  %> ago</i><br />
        <% end %>
      <% end %>
    </p>
  </div>
  <br />
  <% if current_user == @user %>
    <h3> Actions </h3>
    <div class="show_container">
      <p>
        <span class="action" id="action_edit_profile"> <%= image_tag("/images/icons/png-8/16-tool-b.png", :class => "icon") %> <label>Edit Profile</label> </span>
      </p>
    </div>
  <% end %>
</form>

<script type="text/javascript">
  jQuery(document).ready(function(){
    jQuery("#action_edit_profile").click(function(){
      window.location = "<%= edit_user_path(@user) %>";
    });

  })

</script>
